﻿// =============================================
// Author:		Onur Eker
// Create date: <Create Date,,>
// Description:	<Description,,>
// =============================================

using System;
using System.Collections.Generic;
using System.Text;
using Bosphorus.Migrator.Core;
using Bosphorus.Migrator.Core.MigrationCommand;
using Bosphorus.Migrator.Facade.DdlSignature.Base;
using Bosphorus.Migrator.Facade.DdlSignature.Table;
using Bosphorus.Migrator.Facade.DdlSignature.Procedure;
using Bosphorus.Migrator.Implementation.MigrationCommand;
using Bosphorus.Migrator.Model;

namespace Bosphorus.Migrator.Facade
{
    public class Database: DdlSignature<Database>
    {
        public Database(ICommand command) : base(command)
        {
        }

        public static CreateTableSignature Create<TTable>(string name) where TTable : Table, new()
        {
            TTable table = new TTable();
            table.Name = name;
            CreateCommand<Table> createCommand = new CreateCommand<Table>(table);
            return new CreateTableSignature(createCommand);
        }

        public static AlterTableSignature Alter<TTable>(string name, string newName) where TTable : Table, new()
        {
            TTable oldTable = new TTable();
            oldTable.Name = name;

            TTable newTable = new TTable();
            newTable.Name = newName;

            AlterCommand<Table> alterCommand = new AlterCommand<Table>(newTable, oldTable);
            return new AlterTableSignature(alterCommand);
        }

        public static DropTableSignature Drop<TTable>(string name) where TTable : Table, new()
        {
            TTable table = new TTable();
            table.Name = name;
            DropCommand<Table> dropCommand = new DropCommand<Table>(table);
            return new DropTableSignature(dropCommand);
        }

        public static ProcedureSignature Create<TProcedure>(string name, string body) where TProcedure : Procedure
        {
            return new ProcedureSignature(null);
        }
    }
}